package com.zapi.lottery.controller;

import com.zapi.lottery.entity.LotteryPrize;
import com.zapi.lottery.service.LotteryPrizeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * LotteryPrize 控制器
 * 提供抽奖设置的增删改查接口
 * @author: zhonglz
 * @DATE: 2024-06-09
 */
@RestController
@RequestMapping("/lottery/prize")
public class LotteryPrizeController {
    @Autowired
    private LotteryPrizeService lotteryPrizeService;

    /**
     * 新增或更新抽奖设置
     */
    @PostMapping
    public boolean save(@RequestBody LotteryPrize lotteryPrize) {
        return lotteryPrizeService.saveOrUpdate(lotteryPrize);
    }

    /**
     * 删除抽奖设置
     */
    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable Integer id) {
        return lotteryPrizeService.removeById(id);
    }

    /**
     * 根据ID获取抽奖设置
     */
    @GetMapping("/{id}")
    public LotteryPrize getById(@PathVariable Integer id) {
        return lotteryPrizeService.getById(id);
    }

    /**
     * 获取所有抽奖设置列表
     */
    @GetMapping
    public List<LotteryPrize> findAll() {
        return lotteryPrizeService.list();
    }
} 